package org.playground.booking.controller;


import io.swagger.annotations.Api;
import javassist.NotFoundException;
import org.playground.booking.dao.IWechatMerchantAccountDao;
import org.playground.booking.entity.WechatMerchantAccount;
import org.playground.booking.service.IWechatService;
import org.playground.booking.utils.HttpUtils;
import org.playground.booking.utils.PlaygroundBookingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api
@RestController
@RequestMapping(path = "/api/wechat/*")
public class WechatController {

    @Autowired
    private IWechatService wechatService;

    @RequestMapping(path = "openid", method = RequestMethod.GET, produces = "application/json")
    public String getOpenid(@RequestParam String appId,
                            @RequestParam String code) throws PlaygroundBookingException, NotFoundException {
        return wechatService.exchangeOpenid(appId,code);
    }


    //apply wechat payment
    @RequestMapping(path = "applyPayment", method = RequestMethod.POST, produces = "application/json")
    public String applyPayment(String appId, String userId, String openId, Long amount){




        return null;
    }


    //wechat payment notification

    //
}
